package com.github.barteksc.pdfviewer.scroll;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.DashPathEffect;
import android.graphics.Paint;
import android.graphics.Path;
import android.graphics.PathDashPathEffect;
import android.util.AttributeSet;
import android.view.View;

import com.github.barteksc.pdfviewer.util.Util;

public class CropView extends View {
    private Paint mPaint = new Paint();
    private DashPathEffect effects;
    private Path linePath;

    public CropView(Context context){
        this(context, null);
    }
    public CropView(Context context, AttributeSet attrs) {
        super(context, attrs);


        effects = new DashPathEffect(new float[]{5,5,5,5},1);
        mPaint.setAntiAlias(true);

        linePath = new Path();
    }



    @Override
    protected void onDraw(Canvas canvas) {
        super.onDraw(canvas);

        mPaint.setStyle(Paint.Style.FILL);
        mPaint.setColor(Color.parseColor("#26FB4723"));
        canvas.drawRect(getLeft(), getTop(), getRight(), getBottom(), mPaint);

        //draw top line
        mPaint.setStyle(Paint.Style.STROKE);
        mPaint.setColor(Color.parseColor("#FB4723"));
        mPaint.setStrokeWidth(Util.getDP(getContext(), 4));
        mPaint.setPathEffect(effects);

        linePath.reset();
        linePath.moveTo(0, 0);
        linePath.lineTo(getWidth(), 0);

        linePath.moveTo(0, getHeight());
        linePath.lineTo(getWidth(), getHeight());
        canvas.drawPath(linePath, mPaint);
    }
}
